package gui;

import javax.swing.*;
import java.awt.*;

/**
 * Created by Yaksha on 1/22/14.
 */
public class GridPanel extends JPanel{
    public GridPanel() {
        setLayout(new FlowLayout(FlowLayout.CENTER));

        // Initial Wrap Panel (4x1)
        JPanel wrapPanel = new JPanel(new GridLayout(4, 1, 2, 2));

        // 1x1 -> Wrap Panel---------------------------------------
        JLabel fLbl = new JLabel("Input Form");
        fLbl.setHorizontalAlignment(SwingConstants.CENTER);
        fLbl.setFont(new Font("Verdana", Font.BOLD, 24));
        wrapPanel.add(fLbl);

        // 2x1 -> Wrap Panel----------------------------------------
        JPanel inputArea = new JPanel(new GridLayout(3, 2, 8, 8));
        inputArea.setPreferredSize(new Dimension(320, 80));

        JLabel cIdLbl = new JLabel("Course ID");
        cIdLbl.setHorizontalAlignment(SwingConstants.RIGHT);
        inputArea.add(cIdLbl);

        JTextField cIdTxt = new JTextField(20);
        inputArea.add(cIdTxt);

        JLabel cTtLbl = new JLabel("Course Title");
        cTtLbl.setHorizontalAlignment(SwingConstants.RIGHT);
        inputArea.add(cTtLbl);

        JTextField cTtTxt = new JTextField(20);
        inputArea.add(cTtTxt);

        JLabel hLbl = new JLabel("Hours");
        hLbl.setHorizontalAlignment(SwingConstants.RIGHT);
        inputArea.add(hLbl);

        JTextField hTxt = new JTextField(10);
        inputArea.add(hTxt);

        wrapPanel.add(inputArea);

        // 3x1 -> Wrap Panel--------------------------------------
        JLabel btnLbl = new JLabel("Button");
        btnLbl.setHorizontalAlignment(SwingConstants.CENTER);
        btnLbl.setFont(new Font("Verdana", Font.BOLD, 24));
        wrapPanel.add(btnLbl);

        // 4x1 -> Wrap Panel------------------------------------
        JPanel btnArea = new JPanel(new GridLayout(1, 4));

        JButton rsBtn = new JButton("Reset");
        btnArea.add(rsBtn);

        JButton cfBtn = new JButton("Confirm");
        btnArea.add(cfBtn);

        JButton smBtn = new JButton("Submit");
        btnArea.add(smBtn);

        JButton clBtn = new JButton("Cancel");
        btnArea.add(clBtn);

        wrapPanel.add(btnArea);
        // --------------------------------------------------------
        add(wrapPanel);

    }
}
